package socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * User: heihaier@xfuweng.com
 * Date: 2015/7/8
 * Time: 15:01
 */
public class ClientThread implements Runnable {

    private Socket socket;

    private BufferedReader br;

    public ClientThread(Socket socket) throws IOException {

        this.socket = socket;
        this.br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
    }

    @Override
    public void run() {

        String line = null;

        try {
            while ((line = br.readLine()) != null) {

                System.out.println(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
